package DP.iterator.iter.impl;

import DP.iterator.iter.Iterator;

import java.util.Vector;

/**
 * @author msi
 * 具体迭代器
 */
public class ConcreteIterator implements Iterator {

    private Vector vector=new Vector();

    public int cursor=0;

    public ConcreteIterator(Vector vector){
        this.vector=vector;
    }
    @Override
    public Object next() {
        Object result=null;
        if(hasNext()){
            result=this.vector.get(this.cursor++);
        }else {
            result=null;
        }
        return result;
    }

    @Override
    public boolean hasNext() {
       return !(this.cursor==this.vector.size());
    }

    @Override
    public boolean remove() {
        this.vector.remove(this.cursor);
        return true;
    }
}
